package work1.work6.sina;


import java.util.HashSet;

public class Sina {
    private String password;
    private String phone;
    private String name;
    private String email;
    HashSet set = new HashSet();

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
        set.add(name);
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
    public  Sina(){

    }

    public Sina(String password, String phone, String name, String email) {
        this.password = password;
        this.phone = phone;
        this.name = name;
        this.email = email;
    }

    boolean pd1,pd2,pd3,pd4;
    /*判断是否存在用户名*/
    public void Checkame(String name){
        int n=set.size();
        set.add(name);
        if (n==set.size()){
            System.out.println("注册失败，用户重复");
            pd1=false;
        }
        else {
            pd1=true;
        }

    }


    /*判断密码是否一致*/
    public void Checkpassword(String password,String password1){
        if (password.equals(password1)){
            pd2=true;
        }
        else {
            System.out.println("注册失败，密码不一致");
            pd2=false;
        }

    }

    /*判断手机号是否是11位和开头*/

    public void CheckPhone(String phone){
        String bphone=phone.substring(0,2);
        if (bphone.equals("13")||bphone.equals("15")||bphone.equals("17")||bphone.equals("18")){
            if (phone.length()!=11){
                System.out.println("手机号码长度错误");
                pd3=false;
            }
            else {
                pd3=true;
            }
        }
        else {
            System.out.println("手机号开头错误");
            pd3=false;
        }

    }
    /*判断邮箱中是否包含@*/
     public void Checkemail(String email){
        boolean pd = email.contains("@");
        if (!pd){
            System.out.println("邮箱中没有包含@");
            pd4=false;
        }
        else {
            pd4=true;
        }
    }
    void Checkzhuce(){
         if (pd1==pd2==pd3==pd4==true){
             System.out.println("注册成功");
         }
         else {
             System.out.println("注册失败");
         }
    }




}
